package com.qianfeng.propertygroup.controller;

import com.github.pagehelper.PageInfo;
import com.qianfeng.propertygroup.pojo.User;
import com.qianfeng.propertygroup.service.intf.UserService;
import com.qianfeng.propertygroup.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/***
 *
 *   █████▒█    ██  ▄████▄   ██ ▄█▀       ██████╗ ██╗   ██╗ ██████╗
 * ▓██   ▒ ██  ▓██▒▒██▀ ▀█   ██▄█▒        ██╔══██╗██║   ██║██╔════╝
 * ▒████ ░▓██  ▒██░▒▓█    ▄ ▓███▄░        ██████╔╝██║   ██║██║  ███╗
 * ░▓█▒  ░▓▓█  ░██░▒▓▓▄ ▄██▒▓██ █▄        ██╔══██╗██║   ██║██║   ██║
 * ░▒█░   ▒▒█████▓ ▒ ▓███▀ ░▒██▒ █▄       ██████╔╝╚██████╔╝╚██████╔╝
 *  ▒ ░   ░▒▓▒ ▒ ▒ ░ ░▒ ▒  ░▒ ▒▒ ▓▒       ╚═════╝  ╚═════╝  ╚═════╝
 *  ░     ░░▒░ ░ ░   ░  ▒   ░ ░▒ ▒░
 *  ░ ░    ░░░ ░ ░ ░        ░ ░░ ░
 *           ░     ░ ░      ░  
 * Created with IntelliJ IDEA.
 * User: DELL
 * Date: 2020/12/21
 * Time: 20:49
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/users")
    public R getAllUsers(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "5") int pageSize, String username, String dstatus) {
        PageInfo<User> pageInfo = userService.getAllUsers(pageNum, pageSize, username, dstatus);
        return R.setOK(pageInfo);
    }

    @DeleteMapping("/user")
    public R deleteUserByIds(String[] ids) {
        userService.deleteUserByIds(Arrays.asList(ids));
        return R.setOK(null);
    }
}
